/*
 * @Descripttion: vue and node-bs
 * @Author: weijunliang-jul
 * @Date: 2021-02-20 16:23:15
 * @LastEditors: weijunliang-jul
 * @LastEditTime: 2021-02-24 14:55:26
 */
import request from '@/utils/request'

// 获取专业
export function getDepartment() {
    return request({
        url: '/admin/getDepartment',
        method: 'get'
    })
}

// 获取对应身份type的用户
export function getByTypeUser(pageNum, currPage, type) {
    return request({
        url: '/admin/getUsersByTypePage',
        method: 'get',
        params: {
            pageNum: pageNum,
            currPage: currPage - 1,
            type: type
        }
    })
}

// 添加用户 管理员操作
export function addUser(u_id, username, password, sex, type, email, departments, address, classes) {
    return request({
        url: '/admin/person_AddTeacher',
        method: 'post',
        data: {
            u_id: u_id,
            username: username,
            password: password,
            sex: sex,
            type: type,
            email: email,
            departments: departments,
            address: address,
            classes: classes,
        },
    })
}

//删除用户 管理员操作
export function delUser(u_id) {
    return request({
        url: '/admin/delUserdata',
        method: 'get',
        params: {
            u_id: u_id
        }
    })
}

// 分页搜索用户
export function tipSearchUser(input, value, pageSize, pageNo, type) {
    return request({
        url: '/admin/getUsersByTypeAndChar',
        method: 'get',
        params: {
            inputText: input,
            CharType: value,
            pageNum: pageSize,
            currPage: pageNo - 1,
            type: type
        }
    })
}

//更新用户
export function updateUser(uid, username, sex, address, departments, type, email, classes) {
    return request({
        url: '/admin/upUserdata',
        method: 'post',
        data: {
            u_id: uid,
            username: username,
            sex: sex,
            address: address,
            departments: departments,
            type: type,
            email: email,
            classes: classes,
        }
    })
}


// 专业级联查询班级
export function selectClasses(val) {
    return request({
        url: '/admin/DepartmentToGetClass',
        method: 'get',
        params: {
            val
        }
    })
}


// 文件导入 添加用户
export function fileAddUser(type) {
    return request({
        url: '/admin/setXlsxData',
        method: 'post',
        data:{
            type: type
        }
    })
}

